<?php

namespace app\admin\model\dahui;

use think\Model;

class Nianyue2 extends Model
{
    // 表名
    protected $name = 'dahui_nianyue2';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'earlytransfer_text',
        'newjoin_status_text',
        'zc_status_text',
        'refundornot_text'
    ];
    

    
    public function getEarlytransferList()
    {
        return ['否' => __('否'),'是' => __('是')];
    }     

    public function getNewjoinStatusList()
    {
        return ['办理失败' => __('办理失败'),'已办理' => __('已办理'),'未办理' => __('未办理')];
    }     

    public function getZcStatusList()
    {
        return ['办理失败' => __('办理失败'),'已办理' => __('已办理'),'未办理' => __('未办理')];
    }     

    public function getRefundornotList()
    {
        return ['' => __(''),'已退款' => __('已退款'),'待退款' => __('待退款'),'需退款' => __('需退款')];
    }     


    public function getEarlytransferTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['earlytransfer']) ? $data['earlytransfer'] : '');
        $list = $this->getEarlytransferList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getNewjoinStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['newjoin_status']) ? $data['newjoin_status'] : '');
        $list = $this->getNewjoinStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getZcStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['zc_status']) ? $data['zc_status'] : '');
        $list = $this->getZcStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRefundornotTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['refundornot']) ? $data['refundornot'] : '');
        $list = $this->getRefundornotList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function yewu()
    {
        return $this->belongsTo('Yewu', 'businessnumber', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
